package day2018_lab02.test06;

public class Triangle {
    //Triangle类具有类型为double的三个边，以及周长、面积属性，
    // Triangle类具有返回周长、面积以及修改三个边的功能。另外，Triangle类
    // 还具有一个Boolean型的属性，该属性用来判断三个属能否构成一个三角形。
    double a1;
    double a2;
    double a3;
    double c;
    double s;
//返回周长、面积

    public void setA1(double a1) {
        this.a1 = a1;
    }

    public double getA1() {
        return a1;
    }

    public void setA2(double a2) {
        this.a2 = a2;
    }

    public double getA2() {
        return a2;
    }

    public void setA3(double a3) {
        this.a3 = a3;
    }

    public double getA3() {
        return a3;
    }
    public double getC(){
        c=a1+a2+a3;
        return c;
    }
    public double getS(){
        return s= Math.sqrt(getC()/2*(getC()/2-getA3())
                *(getC()/2-getA2())*(getC()/2-getA3()));

    }
    //修改三个边的功能
    public void a4(double a4){
    this.a1=a4;
    }
    public void a5(double a4){
        this.a2=a4;
    }
    public void a6(double a4){
        this.a3=a4;
    }
    public boolean Boolean(){
        if (a1+a2>a3&&a1+a3>a2&&a2+a3>a1){
            return true;
        }else {
            return false;
        }
    }
    Triangle (){}

    public String toString(){
        return "面积"+getS()+"周长"+getC()+"能成否"+Boolean();
    }
}
